/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Responses.DataRetrievalComponents;

import Utilities.Functions;

/**
 * This class represents VirtualBox system data, when retrieved from the system.
 *
 * @author Angel Sanadinov
 */
public class SystemDataComponent extends DataRetrievalComponent
{
    private int serverId; //the id of the server
    private SystemVirtualBoxData virtualBoxData; //data from the IVirtualBox object
    private SystemHostData hostData; //data from the IHost object

    /**
     * Constructs a system data component, using the specified data.
     *
     * @param serverId the server for which this data is valid
     * @param virtualBoxData data from the virtual system (IVirtualBox and ISystemProperties)
     * @param hostData data from the host system (IHost)
     */
    public SystemDataComponent(int serverId, SystemVirtualBoxData virtualBoxData, SystemHostData hostData)
    {
        this.serverId = serverId;
        this.virtualBoxData = virtualBoxData;
        this.hostData = hostData;
    }

    /**
     * Retrieves the id of the server that owns the data.
     *
     * @return the server id
     */
    public int getServerId()
    {
        return serverId;
    }

    /**
     * Retrieves the VirtualBox system data.
     *
     * @return the data
     */
    public SystemVirtualBoxData getVirtualBoxData()
    {
        return virtualBoxData;
    }

    /**
     * Retrieves the Host system data.
     *
     * @return the data
     */
    public SystemHostData getHostData()
    {
        return hostData;
    }

    @Override
    public boolean isValid()
    {
        if(Functions.isServerIdValid(serverId) && hostData != null && hostData.isValid()
                && virtualBoxData != null && virtualBoxData.isValid())
            return true;
        else
            return false;
    }

    @Override
    public String toString()
    {
        return serverId + "," + virtualBoxData + "," + hostData;
    }
}
